<%--
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>评论管理</title>
</head>
<body>
<h1>评论管理</h1>
<table border="1">
  <tr>
    <th>评论ID</th>
   &lt;%&ndash; <th>文章ID</th>&ndash;%&gt;
    <th>评论内容</th>
    <th>评论作者</th>
    <th>评论时间</th>
    <th>操作</th>
  </tr>
  <c:forEach items="${comments}" var="comment">
    <tr>
      <td>${comment.id}</td>
      &lt;%&ndash;<td>${comment.articleId}</td>&ndash;%&gt;
      <td>${comment.content}</td>
      <td>${comment.author}</td>
      <td>${comment.formattedCreated}</td>
      <td>
        <a href="${pageContext.request.contextPath}/deleteComment?id=${comment.id}">删除</a>
      </td>
    </tr>
  </c:forEach>
</table>
</body>
</html>--%>
<%@page pageEncoding="UTF-8" contentType="text/html; UTF-8" isELIgnored="false" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>评论管理</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
        }

        body {
            background: linear-gradient(135deg, #fae18e 0%, #e4edf5 100%);
            min-height: 100vh;
            padding: 20px;
            color: #2c3e50;
        }

        .admin-container {
            max-width: 1200px;
            margin: 0 auto;
        }

        /* 头部样式 */
        .admin-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
            padding: 20px 0;
            border-bottom: 2px solid rgba(242, 153, 74, 0.2);
        }

        .admin-header h1 {
            font-size: 2.2rem;
            color: #e67e22;
            display: flex;
            align-items: center;
        }

        .admin-header h1 i {
            margin-right: 12px;
            background: linear-gradient(135deg, #e67e22, #f39c12);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        /* 按钮样式 */
        .admin-buttons {
            display: flex;
            gap: 15px;
        }

        .btn {
            padding: 12px 24px;
            border-radius: 30px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            border: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            text-decoration: none;
            font-size: 16px;
        }

        .btn i {
            margin-right: 8px;
        }

        .btn-home {
            background: #f1c40f;
            color: #fff;
            box-shadow: 0 4px 15px rgba(241, 196, 15, 0.35);
        }

        .btn-home:hover {
            background: #f39c12;
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(241, 196, 15, 0.45);
        }

        .btn-add {
            background: linear-gradient(135deg, #e67e22, #f39c12);
            color: white;
            box-shadow: 0 4px 15px rgba(230, 126, 34, 0.35);
        }

        .btn-add:hover {
            background: linear-gradient(135deg, #f39c12, #e67e22);
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(230, 126, 34, 0.45);
        }

        /* 表格容器 */
        .table-container {
            background: white;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
            overflow: hidden;
            margin-bottom: 30px;
            animation: fadeIn 0.6s ease-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* 表格样式 */
        .admin-table {
            width: 100%;
            border-collapse: collapse;
            border-spacing: 0;
        }

        .admin-table thead {
            background: linear-gradient(135deg, #f39c12, #e67e22);
            color: white;
        }

        .admin-table th {
            padding: 16px 20px;
            text-align: left;
            font-weight: 600;
            font-size: 16px;
        }

        .admin-table tbody tr {
            border-bottom: 1px solid #f1f2f6;
            transition: all 0.3s ease;
        }

        .admin-table tbody tr:hover {
            background-color: #fffaf0;
        }

        .admin-table td {
            padding: 16px 20px;
            color: #2c3e50;
        }

        .admin-table .title-cell {
            font-weight: 600;
            color: #e67e22;
        }

        .admin-table .content-cell {
            max-width: 300px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .admin-table .action-cell {
            display: flex;
            gap: 12px;
        }

        .action-link {
            display: inline-flex;
            align-items: center;
            padding: 8px 16px;
            border-radius: 6px;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .edit-link {
            background: rgba(52, 152, 219, 0.1);
            color: #3498db;
        }

        .edit-link:hover {
            background: rgba(52, 152, 219, 0.2);
            transform: translateY(-2px);
        }

        .delete-link {
            background: rgba(231, 76, 60, 0.1);
            color: #e74c3c;
        }

        .delete-link:hover {
            background: rgba(231, 76, 60, 0.2);
            transform: translateY(-2px);
        }

        /* 空状态提示 */
        .empty-state {
            text-align: center;
            padding: 60px 20px;
        }

        .empty-state i {
            font-size: 64px;
            color: #f1c40f;
            margin-bottom: 20px;
            opacity: 0.7;
        }

        .empty-state h3 {
            color: #e67e22;
            margin-bottom: 15px;
            font-size: 24px;
        }

        .empty-state p {
            color: #7f8c8d;
            font-size: 18px;
            max-width: 500px;
            margin: 0 auto;
        }

        /* 文章数量提示 */
        .count-info {
            background: rgba(241, 196, 15, 0.1);
            border-left: 4px solid #f1c40f;
            padding: 15px;
            border-radius: 0 8px 8px 0;
            margin: 20px 0;
            font-size: 16px;
            color: #7f8c8d;
        }

        .count-info strong {
            color: #e67e22;
            font-weight: 600;
        }

        /* 响应式设计 */
        @media (max-width: 992px) {
            .admin-table {
                display: block;
                overflow-x: auto;
            }

            .admin-header {
                flex-direction: column;
                gap: 20px;
                text-align: center;
            }

            .admin-buttons {
                width: 100%;
                justify-content: center;
            }
        }

        @media (max-width: 768px) {
            .admin-table th, .admin-table td {
                padding: 12px 15px;
            }

            .action-cell {
                flex-direction: column;
                gap: 8px;
            }

            .action-link {
                width: 100%;
                justify-content: center;
            }
        }
    </style>
</head>
<body>
<div class="admin-container">
    <div class="admin-header">
        <h1>评论管理</h1>
        <div class="admin-buttons">
            <button class="btn btn-home" onclick="window.location.href='welcome'">
                <i class="fas fa-home"></i> 返回首页
            </button>

        </div>
    </div>

    <!-- 评论数量信息 -->
    <div class="count-info">
        <i class="fas fa-info-circle"></i>
        <c:choose>
            <c:when test="${empty comments}">
                当前没有评论数据
            </c:when>
            <c:otherwise>
                共<strong>${comments.size()}</strong>条评论</strong>
            </c:otherwise>
        </c:choose>
    </div>

    <div class="table-container">
        <c:choose>
            <c:when test="${empty comments}">
                <div class="empty-state">
                    <i class="fas fa-file-alt"></i>
                    <h3>没有评论数据</h3>
                    <p>您还没有发表任何评论，可以去博文里评论内容</p>
                </div>
            </c:when>
            <c:otherwise>
                <table class="admin-table">
                    <thead>
                    <tr>
                        <%--<th>评论ID</th>--%>
                        <%--<th>文章ID</th>--%>
                        <th>评论内容</th>
                        <th>评论作者</th>
                        <th>评论时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${comments}" var="comment">
                        <tr>
                            <%--<td class="title-cell">${comment.id}</td>--%>
                            <td class="content-cell">${comment.content}</td>
                            <td><fmt:formatDate value="${comment.created}" pattern="yyyy-MM-dd" /></td>
                            <td>${comment.author}</td>
                            <td class="action-cell">
                                <a href="deleteComment?id=${comment.id}" class="action-link delete-link"
                                   onclick="return confirm('确定要删除这条评论吗？此操作不可恢复。')">
                                    <i class="fas fa-trash-alt"></i> 删除
                                </a>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </c:otherwise>
        </c:choose>
    </div>
</div>

<script>
    // 添加简单的行动画效果
    document.addEventListener('DOMContentLoaded', function() {
        const rows = document.querySelectorAll('.admin-table tbody tr');

        rows.forEach((row, index) => {
            row.style.opacity = 0;
            row.style.transform = 'translateX(-20px)';

            setTimeout(() => {
                row.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
                row.style.opacity = 1;
                row.style.transform = 'translateX(0)';
            }, 100 * index);
        });
    });
</script>
</body>
</html>
